# Contributor: rubicon <rubicon@mailo.com>
# Maintainer:
pkgname=ocaml-asn1-combinators
_pkgname=asn1-combinators
pkgver=0.2.6
pkgrel=0
pkgdesc="Embed typed ASN.1 grammars in OCaml"
url="https://github.com/mirleft/ocaml-asn1-combinators"
arch="all !riscv64"  # limited by ocaml aport
license="ISC"
depends="ocaml-runtime ocaml-cstruct ocaml-ptime ocaml-zarith"
# ocaml-zarith is not separated into a -dev subpackage
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-cstruct-dev ocaml-ptime-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-alcotest-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/mirleft/ocaml-asn1-combinators/releases/download/v$pkgver/asn1-combinators-v$pkgver.tbz"
builddir="$srcdir/$_pkgname-v$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
4c1b28f1d230395ff1ad3b8e8d03981b10015062ec270f29e2521914eb64c2fa4d5df68363e339e9a1158c3b58aef0e25156f7ec6addd85a580fecadc17edfac  ocaml-asn1-combinators-0.2.6.tar.bz2
"
